package com.sk.bilibili.utils;

import android.content.Context;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.PopupMenu;

import androidx.annotation.MenuRes;
import androidx.constraintlayout.widget.ConstraintLayout;

public class PopupMenuUtils {

    public static void showPopupMenu(Context context, View view,@MenuRes int res,
                                     PopupMenu.OnMenuItemClickListener listener){
        PopupMenu menu = createPopupMenu(context, view, res);
        menu.setOnMenuItemClickListener(listener);
        menu.show();
    }

    public static PopupMenu createPopupMenu(Context context, View view,@MenuRes int res){
        PopupMenu menu = new PopupMenu(context, view);
        MenuInflater inflater = menu.getMenuInflater();
        inflater.inflate(res,menu.getMenu());
        return menu;
    }

}